<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %> 
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta name="renderer" content="webkit">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>客户列表</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>

<script type="text/javascript">
	var grid = null;
	var flag = '${flag}';
	var cstRlFlag = '${cstRlFlag}';
	$(function () {
	    initForm();
		setCstClTypCd();
		initGrid();//注意初始化要在initForm之后,因为在初始化grid的时候需要form参数
	    searchBtnEvent();
	    clearBtnEvent();
	});
	//选择担保人时，设置客户属性不可选
	function setCstClTypCd(){
		var cstRlFlag = '${cstRlFlag}';
		var cstTypCd = ProjectConstant.CST_RL_SPONSOR;
		if(cstRlFlag==cstTypCd){
		/* 	 var slt=liger.get("cstRlTyp");
	            slt.setDisabled();
	            slt.setValue(cstTypCd); */
			$("#cstTypCd").val(cstTypCd);
			
		}
		var cstTypCd = '${cstTypCd}';
		$("#cstTypCd").val(cstTypCd);
	}
	
	//清空按钮事件
	function clearBtnEvent(){
		 $("#clearBtn").click(function(event) {
		        $("#resetBtn").click();  //重置 input-text
		        var form = liger.get("searchBar");
		        form.setData({  //重置select等特殊表单
		            "cstTypCd":" ",
		            "cstNm":" "
		          //  "cstRlTyp":" ",
		        });
		 });
	}
	
	//初始化表单
	function initForm(){
		$("#searchBar").ligerForm();
	}
	
	//查询按钮事件
	function searchBtnEvent(){
		 $("#searchBtn").click(function(event) {
	         var form = new liger.get("searchBar");
	         var data = form.getData();
	        
	         for (name in data){
	            grid.setParm(name,data[name]);
	         };
	        grid.reload();
	    });
	}
	
	//查询参数
	function getSearchParams(){
		var form = new liger.get("searchBar");
        var data = form.getData();
        return data;
	}
	
	//初始化列表
	function initGrid(){
			
		$("#ligergrid1").ligerGrid({
	    	url: '<%=path%>/rfbuss/fncprjbscinfo/initPayList2.do',
	    	method : 'get',
	    	parms:getSearchParams(),
	        columns: [
	            { display: '开户行名', name: 'bkNm',  width: 100, minWidth: 60 }, 
	              { display: '账户名称', name: 'accNm',  width: 100, minWidth: 60 },
	              { display: '账号', name: 'accNo', width: 120},
	            {
	                display: '操作',
	                isSort: false,
	                width: 100,
	                render: function (rowdata, rowindex, value){
	                     var h='<a class="sq-button-hasicon" href="javascript:chooseCstRow(';
	                        h+="'"+rowdata.id+"',";
	                        h+="'"+rowdata.bkNm+"',";
	                        h+="'"+rowdata.accNm+"',";
	                        h+="'"+rowdata.accNo+"'"; 
	                       
	                        h+=')"><i class="sqBtnIco_3"></i>选择</a>'
	                    return h; 
	                }
	            }
	        ],
	        pageSize:10,
	        root:'rows',
	        record:'total',
	        hideLoadButton : true,
	        width: '100%',
	        height:'100%',
	        heightDiff:-2,
	        checkbox:false,
	        rownumbers:true
	    });
	    grid = liger.get("ligergrid1");
	    grid.setHeight(100);
	}
	
	//格式化时间
	function renderDate(rowdata, index, value){
		var dateStr = "";
		if(null != value){
			var date = new Date(value);
			dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
		}
		return dateStr;
	}
	
	
		
	
	function clearBtn(){
		var form = new liger.get("searchBar");
		form.clear();
	}
	
	function iframeResize () {
	    if (parent.mainApp) {
	        parent.mainApp.parentTab.onResize();
	    };
	}
	function chooseCstRow(id,bkNm,accNm,accNo){
		//alert(id+"="+bkNm+"="+accNm+"="+accNo)
		if(flag=="pwa"){
			parent.window.document.getElementById("accNo").value=accNo;
			parent.window.document.getElementById("expwdacc").value=id;
			parent.window.document.getElementById("expwdbank").value=bkNm;			
		}
		if(flag=="ocr"){
			parent.window.document.getElementById("accNo").value=accNo;
			parent.window.document.getElementById("transAcc").value=id;
			parent.window.document.getElementById("transBank").value=bkNm;	
			setHtmlById("accNm",accNm);
		}
		if(flag=="tran"){
			parent.window.document.getElementById("accNotem").value=accNo;
			parent.window.document.getElementById("transacctem").value=id;
			parent.window.document.getElementById("transbanktem").value=bkNm;
			setValueById("accNotemNm",accNm);
			window.parent.document.getElementById("hiddenBtn").click();
		}
		
		frameElement.dialog.close();
		// parent.grid.reload();
	}
	
	//设置前页面元素的值
	function setHtmlById(id,value) {
		if(parent.window.document.getElementById(id)) {
			return parent.window.document.getElementById(id).innerHTML  = value;
		}
	}
	//设置前页面元素的值
	function setValueById(id,value) {
		if(parent.$("#"+id)) {
			return parent.$("#"+id).val(value);
		}
	}
	
</script>

<body class="iframeBody">
<div class="Wrapper">
<div class="searchArea">
    <form id="searchBar">
        <div class="fieldset1 clearFix">
            <div class="fieldBox">
                <div class="label">开户行</div>
                <div class="field">
                    <input name="bkNm" id="bkNm" type="text" class="ui-textbox" value="">
                </div>
            </div>
            <div class="fieldBox">
                <div class="label">账号</div>
                <div class="field">
                    <input name="accNo" id="accNo" type="text" class="ui-textbox" value="">
                </div>
            </div>      
      
            <div class="clearFix"></div>
            <div class="btnsBox">
               <span id="searchBtn"  class="sq-button sq-button-round"><!-- <i class="sqBtnIco_1"></i> -->查询</span>
               <span id="clearBtn" class="sq-button sq-button-round"><!-- <i class="sqBtnIco_19"></i> -->清空</span>
               <input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
            </div>
        </div>
        </form>
    </div>
</div>
<div id="ligergrid1" class="sq-grid"></div>
</div>
</body>
</html>